import json

from django.http import HttpResponse
from django.shortcuts import render
from .functions import salarysclass


# Create your views here.
def get_salary(request):
    """
    登录接口
    :param request:
    :return:
    """
    token = request.headers['token']
    # 根据token获取管辖部门信息，再获取管辖范围内的人
    return_data = salarysclass.get_salary(token,
                                          request.GET['name'] if 'name' in request.GET.keys() else '',
                                          request.GET['period'] if 'period' in request.GET.keys() else '',
                                          int(request.GET['page']) if 'page' in request.GET.keys() else '',
                                          int(request.GET['limit']) if 'limit' in request.GET.keys() else '',
                                          )
    return HttpResponse(json.dumps(return_data))
